﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using FXnaInfrastructure;


namespace GWModflow
{

    /// <summary>
    /// 通用源汇集合基类
    /// </summary>
    [Serializable]
    public abstract class SSCollection
    {

        public SSCollection(ModflowModel model)
        {
            this._modflowModel = model;

        }



        bool _enabled = false;


        /// <summary>
        /// 是否启用
        /// </summary>
        public bool Enabled
        {
            get { return _enabled; }
            set { _enabled = value; }
        }


        ModflowModel _modflowModel;

        public ModflowModel ModflowModel
        {
            get { return _modflowModel; }
            set { _modflowModel = value; }
        }




        protected List<SSBase> _innerList = new List<SSBase>();

        public List<SSBase> InnerList
        {
            get { return _innerList; }
            set { _innerList = value; }
        }


     









        //protected IDGenerator _IDGenerator;

        //public IDGenerator IDGenerator
        //{
        //    get { return _IDGenerator; }
        //    set { _IDGenerator = value; }
        //}



        #region 公共方法

        public List<SSBase> GetGHB(int index)
        {
            List<SSBase> heads = new List<SSBase>();


            foreach (SSBase item in this._innerList)
            {
                if (item.Index == index)
                {

                    heads.Add(item);

                }


            }

            return heads;
        }


        public void UpdateGHB(List<SSBase> ghbs, List<int> indices)
        {

            //取得所有的index元素

            List<SSBase> orgHeads = new List<SSBase>();

            foreach (int index in indices)
            {
                orgHeads.AddRange(this.GetGHB(index));

            }


            foreach (SSBase head in orgHeads)
            {
                this._innerList.Remove(head);


            }


            this._innerList.AddRange(ghbs);

         




        }


        public void ResetGHB(List<SSBase> ghbs)
        {
            this._innerList.Clear();

            this._innerList.AddRange(ghbs);

           


        }

    
    


        public void Clear()
        {
           
            this._innerList.Clear();

          

        }




     

        public virtual void WriteFile(string fname)
        {



        }


        #endregion



    }
}
